/*
 * redirect.cpp
 *
 *  Created on: Mar 18, 2024
 *      Author: liaofd
 *  new(size)
 *  delete ptr
 *  new type[size]
 *  delete []ptr
 */
#include "FreeRTOS.h"
#include <new>

void* operator new(size_t size) {
	void *ptr = pvPortMalloc(size);
	if (ptr == NULL) {
		throw std::bad_alloc();
	}
	return ptr;
}

void operator delete(void *ptr) noexcept {
	vPortFree(ptr);
}

void* operator new[](size_t size) {
	return operator new(size);
}

void operator delete[](void *ptr) noexcept {
	operator delete(ptr);
}

